import request from  '@/utils/request'

// 枚举地址
enum API{
        SPUURL = '/admin/product/',
        //获取全部品牌接口
        TMURL="/admin/product/baseTrademark/getTrademarkList",
        //全部销售属性接口
        ALLSALEATTR='/admin/product/baseSaleAttrList',
        //已有SPU照片墙的接口
        IMGLIST="/admin/product/spuImageList/",
        //获取【SPU】已有的销售苏醒
        HAVESALEATTR="/admin/product/spuSaleAttrList/",
        // 添加SPU
        ADD='/admin/product/saveSpuInfo',
        // 修改SPU
        UPDATE='/admin/product/updateSpuInfo',
}

// //获取某一个三级分类下的全部SPU
export const reqSpuList = (page:number,limit:number,category3Id:string|number)=>request.get(API.SPUURL+`${page}/${limit}?category3Id=${category3Id}`)
//获取全部品牌接口
export const reqAllaTradeMark =()=>request.get(API.TMURL);
//全部销售属性接口
export const reqAllSaleAttr = ()=>request.get(API.ALLSALEATTR);
//已有SPU照片墙的接口
export const reqImgList = (spuId:number)=>request.get(API.IMGLIST+spuId);
//获取【SPU】已有的销售苏醒
export const reqSpuHasSaleAttr=(spuId:number)=>request.get(API.HAVESALEATTR+spuId);


// 添加或修改SPU
export const reqAddOrUpdateSpu  = (data:any)=>{
     if(data.id){
        // 修改
      return  request.post(API.UPDATE,data)
     }else{
        return request.post(API.ADD,data)
     }
}